package com.agp.controller.admin;

import com.agp.dto.UerPageQueryDTO;
import com.agp.dto.UpdateUserDTO;
import com.agp.result.PageResult;
import com.agp.result.Result;
import com.agp.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 管理用户接口
 */
@RestController
@RequestMapping("/admin/user")
@Api(tags = "管理用户接口")
@Slf4j
public class ManagementController {
    @Autowired
    private UserService userService;

    /**
     * 分页查询用户接口
     */
    @GetMapping("/page")
    @ApiOperation("分页查询用户接口")
    public Result<PageResult> page( @Validated UerPageQueryDTO pageQueryDTO) {
        log.info("分页查询{}", pageQueryDTO);
        PageResult pageResult =  userService.page(pageQueryDTO);
        return Result.success(pageResult);
    }

    /**
     * 批量禁用用户接口
     */
    @PutMapping("/disable")
    @ApiOperation("禁用用户接口")
    public Result disable(@RequestBody UpdateUserDTO updateUserDTO){
        log.info("修改用户状态{}", updateUserDTO);
        userService.updateUserStatus(updateUserDTO);
        return Result.success();
    }









}
